package sort.leetcode.easy;

import java.util.Arrays;

/**
 * @author bruin_du
 * @description 扑克牌中的顺子
 * @date 2022/5/31 10:03
 **/
public class Offer61_IsStraight {
    public boolean isStraight(int[] nums) {
        Arrays.sort(nums);
        int count0 = 0;
        for (int i = 0; i < nums.length - 1; i++) {
            if(nums[i] != 0 && nums[i] == nums[i + 1]) return false;
            if(nums[i] == 0) count0++;
        }
        return nums[nums.length - 1] - nums[count0] <= 4;
    }
}
